package com.hyt.it.ogt.ykcj.common.utils;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class ListUtil {


    public static List<String> getDiffrent(List<String> list1, List<String> list2){
        if (null == list1 || list1.isEmpty())
            return list2;
        if (null == list2 || list2.isEmpty())
            return list1;
        Map<String,Integer> map = new HashMap<String,Integer>(list1.size()+list2.size());
        List<String> diff = new ArrayList<String>();
        List<String> maxList = list1;
        List<String> minList = list2;
        if(list2.size()>list1.size()){
            maxList = list2;
            minList = list1;
        }

        for (String string : maxList){
            map.put(string, 1);
        }

        for (String string : minList){
            Integer cc = map.get(string);
            if(cc!=null){
                map.put(string, ++cc);
                continue;
            }
            map.put(string, 1);
        }

        for(Map.Entry<String, Integer> entry:map.entrySet()){
            if(entry.getValue()==1)
            {
                diff.add(entry.getKey());
            }
        }
        return diff;
    }
}